<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <link href="__PUBLIC__/checkin/css/base.css" rel="stylesheet">
    <link href="__PUBLIC__/checkin/css/index.css" rel="stylesheet">
    <link rel="stylesheet" href="__PUBLIC__/checkin/css/usercenter.css" type="text/css">
    <title>签到中心</title>
    <script src="__PUBLIC__/checkin/js/rem.js"></script>
    <script src="__PUBLIC__/checkin/js/jquery-1.7.2.js"></script>
    <script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script type="text/javascript">
        var prom_url = '';
        var conf = '';
        wx.config( conf = {
            //// 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印
            debug: true, 
            appId: '<?php echo $appid; ?>', // 必填，公众号的唯一标识
            timestamp: '<?php echo $timestamp; ?>', // 必填，生成签名的时间戳
            nonceStr: '<?php echo $nonceStr; ?>', // 必填，生成签名的随机串
            signature: '<?php echo $signature; ?>',// 必填，签名，见附录1
            jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
        });
        wx.ready(function(){
            wx.onMenuShareAppMessage({
                title: "<?php echo $sysinfo['share_title']; ?>", // 分享标题
                desc: "<?php echo $sysinfo['share_descr']; ?>", // 分享描述
                link: prom_url, // 分享链接
                imgUrl: '', // 分享图标
                type: 'link', // 分享类型,music、video或link，不填默认为link
                dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                success: function (r) { 
                    console.log(r);
                    // 用户确认分享后执行的回调函数
                    //share_counter
                    $.ajax({
                        url: "<?php echo U('checkin/ShareAppMessageSuccess'); ?>",
                        type: "POST",
                        success: function(res){
                            alert(res);
                        }
                    })
                },
                cancel: function () { 
                // 用户取消分享后执行的回调函数
                }
            });
            wx.onMenuShareTimeline({
                title: "<?php echo $sysinfo['share_title']; ?>", // 分享标题
                link: prom_url, // 分享链接
                imgUrl: '', // 分享图标
                success: function () { 
                    // 用户确认分享后执行的回调函数
                },
                cancel: function () { 
                    // 用户取消分享后执行的回调函数
                }
            });
        });
   /*
        $(function(){

            var html="<small class='addBonus'>+"+"<?php echo $data['points'] ?>"+"</small>";
            var t=null;
            function showBonus(){
                $("body").append(html);
                $(".addBonus").addClass('zoomIn').show();
                t=setTimeout(function(){
                    $(".addBonus").removeClass('zoomIn');
                    $(".addBonus").addClass('zoomOut')
                    $(".addBonus").animate({'top':'50%'},1000,function(){
                        $(".addBonus").remove();
                    });
                },2000)
            }

            var points_checkin_url = "checkin.php?act=ajax_checkin";
            $("#signBtn").on('click',function(){
                var store_id = "<?php echo $store_id ?>";
                clearTimeout(t);
                $.post(points_checkin_url, {store_id:store_id}, function(result){
                    if (typeof(result) == 'object') {
                        if (result.err_code) {
                            alert(result.err_msg);
                        } else {
                            $("#signBtn").remove();
                            $("#signText").text("您今天已经获得 <?php echo $data['points'] ?> 积分");
                            showBonus();
                        }
                    } else {
                        alert('系统异常，请重试提交');
                    }
                });
            });


        });
*/
    $(document).ready(function(){
        var html="<small class='addBonus'>xxx</small>";
        var t=null;
        function showBonus(){
            $("body").append(html);
            $(".addBonus").addClass('zoomIn').show();
            t=setTimeout(function(){
                $(".addBonus").removeClass('zoomIn');
                $(".addBonus").addClass('zoomOut')
                $(".addBonus").animate({'top':'50%'},1000,function(){
                    $(".addBonus").remove();
                });
            },2000)
        }
        $('#signBtnWaiting').hide();
        //$("#signText").hide();
        
        $("#signBtn").click(function(){
            $("#signBtn").hide();
            $('#signBtnWaiting').fadeIn();
               // clearTimeout(t);
            $.ajax({
                url: "<?php echo U('checkin'); ?>",
                data: {
                    rand: "<?php echo $ajaxValidationStr; ?>",
                },
                type: 'POST',
                dataType: 'JSON',
                //dataType: 'text',
                success: function(data){
                    //alert(JSON.stringify(data));return;
                    //$("#signBtn").();
                    if(data.errcode == 0){
                        $('#signBtnWaiting').toggle();
                        $("#signBtn").remove();
                        html="<small class='addBonus'>" + data.bonus + "</small>";
                        //$("#signText").show();
                        $("#signText").text("您今天已经获得 " + data.bonus + " 元签到奖励");
                        showBonus();
                    } else {
                        alert(data.errmsg);
                    }
                },
                error: function(xhr){
                    $('#signBtnWaiting').fadeOut();
                    $("#signBtn").show();
                    alert('error!');
                },
            })
        });
        
        // 分享遮罩
        $(".js-btn-copy").click(function () {
            $("#js-share-guide").removeClass("hide");
        });
        
        $("#js-share-guide").click(function () {
            $("#js-share-guide").addClass("hide");
        });
    });
    </script>
    <script>
        $(document).ready(function(){
            $.get("<?php echo U('qrcode'); ?>", {}, function(data){
                $('#prom-qr-code').attr('src', data.data.qrcode_url);
                $('#prom-url').val(data.data.url_link);
                prom_url=data.data.url_link;
            }, 'JSON');
        });
    </script>
</head>
<body>
<div class="signIn">
    <div class="signInBanner">
       <img src="__PUBLIC__/checkin/images/share_banner.png"/>
    </div>
    <?php $checkin_mode = explode('|', $sysinfo['checkin_mode']);?>
    <div class="task">
        <div class="blueTitle">任务区</div>
            <p>从 24hrs（<?php echo date('Y-m-d H:i:s', $time_from);?> ） 到现在（<?php echo date('Y-m-d H:i:s', $time_to);?> ）︎</p>
        <div class="row">
            <h3><i></i>任务一</h3>
            <p>☑☐分享到朋友/微信群 <?php echo $stat_data['unfinished']['s2s'] + $stat_data['finished']['s2s'];?> 次。（To PM: 后台以后加）︎</p>
            
            <div class="copyUrl">
                <a class="fr" href="<?php echo U('checkin/index'); ?>">去分享</a>
            </div>
            
        </div>
        <div class="row">
            <h3><i></i>任务二</h3>
            <p>☑☐分享到朋友圈 <?php echo $stat_data['unfinished']['s2tl'] + $stat_data['finished']['s2tl'];?> 次。（To PM: 后台以后加）︎</p>
            <p>Ask PM: 分享到朋友圈 24 小时内需要几次？什么时候算第一次？</p>
            <div class="copyUrl">
                <a class="fr" href="<?php echo U('checkin/index'); ?>">去分享</a>
            </div>
        </div>
        <div class="row">
            <h3><i></i>任务三</h3>
            <p>☑☐<?php echo $stat_data['finished']['s2tl'] + $stat_data['finished']['s2s'];?> 人通过分享进入本游戏（To PM: 后台以后加）︎</p>
            <p>Ask PM: 分享到朋友圈 24 小时内需要几次？什么时候算第一次？</p>
        </div>
    </div>
    <div class="follow">
        <div class="followWrap">
            <h2><em>您尚未有资格兑换！赶快去完成任务吧！</em></h2>
            <div class="clearfix followInfo">
                <div class="followMe" style="width: 100%;">
                    <div class="followText" style="">
                        <a href="<?php echo U('checkin/index'); ?>" style="font-size: .5rem; background: #ffc207; border-radius: .25rem; padding: .3rem .5rem; color: #fff;">去分享！</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="js-share-guide" class="js-fullguide fullscreen-guide hide" style="font-size: 16px; line-height: 35px; color: #fff; text-align: center;"><span class="js-close-guide guide-close">×</span><span class="guide-arrow"></span><div class="guide-inner">请点击右上角<br>通过【发送给朋友】功能<br>把信息分享给朋友～</div></div>


<link href="__PUBLIC__/css/base.css" rel="stylesheet" type="text/css">
<link href="__PUBLIC__/Weixin/css/index.css?v={:rand(0,99)}" rel="stylesheet" type="text/css">
<link href="__PUBLIC__/Weixin/css/head.css?v={:rand(0,99)}" rel="stylesheet" type="text/css">
<include file="Index/menu" />
</body>
</html>
